/**
 * @Author: lusx
 * @Date:   21-03-2019 09:54:34
 * @Project: Govern督办
 * @Last modified by:   lusx
 * @Last modified time: 22-03-2019 05:15:05
 */
import { observable, action } from "mobx";
import { BrowserHrm } from "weaver-mobile-page";
import { SupStore } from "../supStore.js";
import agentStore from "./agentStore.js";
export default class OthersStore extends SupStore {
  @observable pageKey = ""; //页面的标志
  id = ""; //页面id
  type = ""; //页面类型,比如成文 页面类型为2;
  @observable searched = false; //搜索完后,避免页面执行初始化动作
  constructor(props) {
    super(props);
    this.init = this.init.bind(this);
    this.clickFloatTouch = this.clickFloatTouch.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }
  @action
  init(params) {
    const { key, ...newParams } = params;
    this.pageKey = key;
    this.id = params.id;
    this.type = params.type;
    agentStore.Requests.get(key, newParams).then(data => {
      let dataKey = {
        dataKey: data.sessionkey
      };
      this.list.getData(dataKey);
    });
  }
  @action
  clickFloatTouch(params) {
    this.browserHrm = new BrowserHrm.Store({ route: params, id: "mulHrm" });
  }
  @action
  handleSubmit() {
    const params = {
      id: this.id,
      type: this.type,
      reporter: this.reporter,
      reportDate_select: this.reportDate_select,
      reportDate_start: this.reportDate_start,
      reportDate_end: this.reportDate_end
    };
    const key = this.pageKey;
    this.searched = true;
    agentStore.Requests.get(key, params)
      .then(data => {
        let dataKey = {
          dataKey: data.sessionkey
        };
        this.list.getData(dataKey);
        
      })
      // .finally(() => {
      //   this.clearInfoSearch();
      // });
      return Promise.resolve(true)
  }
  @action
  clear() {
    this.searched = false;
  }
}
